#include ("/_includes/_layout.html")
#@layout("小程序发布", "wxmall,点步科技", "Wxmall社区","wxmall") 
#define content()
<div class="wrapper wrapper-content">
	<div id="tableList" class="content  ibox-content">
		<div class="panel-body">
			<div style="float: left; margin-right: 20px;"><a href="#(webctx)/weapp/sets/step1" class="btn btn-info">提交审核
			&nbsp;<i class="fa fa-question-circle" onmouseout="layer.closeAll();" onmouseover="layer.tips('选择模板，预览体验后，提交到微信官方审核。', this, {tips: [1, '#3595CC'],time: 0});"></i>
			</a>
			<a id="publish_online" href="javascript:void(0)" class="btn btn-default">发布上线
			&nbsp;<i class="fa fa-question-circle" onmouseout="layer.closeAll();" onmouseover="layer.tips('如果有微信官方审核通过的版本，点击此按钮发布到线上，发布上线后，会替换原来旧版本的小程序。', this, {tips: [1, '#3595CC'],time: 0});"></i>
			</a>
			</div>
			<div id="pager" class="jqpager" style="margin-bottom: 1px;"></div>	
		</div>
		<table id="mainTable" class="table table-striped table-bordered bootstrap-datatable datatable" border="0">
		  <thead>
			  <tr>
				<th><input type="checkbox" id="all" title="全选/反选" style="margin-right: 4px; vertical-align: middle;"/></th>
				<th>审核编号</th>
				<th>审核状态</th>
				<th>审核信息</th>
				<th>审核时间</th>
				<th>发布时间</th>
			  </tr>
		  </thead>   
		  <tbody class="itemsLotGrid">								
		  </tbody>
	  	</table>
	</div>
</div>
<!-- html 模板文件 -->
<script type="text/template" id="item_table_tr_tpl">
{{each list as item i}}
		<tr class="package">
			<td><input type="checkbox" class="commchk" id="checkbox_{{item.id}}" style="margin-right: 4px; vertical-align: middle;"/></td>
			<td>{{item.auditid}}</td>
			<td><span>{{if item.status == 0}} 审核通过 {{else if item.status==1}} 审核失败 {{else}} 审核中 {{/if}}</span></td>
			<td><span>{{item.reason}}</span></td>
			<td><span>{{item.created}}</span></td>
			<td><span>{{item.updated}}</span></td>
		</tr>
{{/each}}
</script>
<script type="text/template" id="table_noresult_tr_tpl">
	<tr class="package"><td colspan="6" class="center">没有结果集</td></tr>
</script>
#end
<script type="text/javascript">
$(document).ready(function() {
	var params = {};
	var table = new obz.TableView("pager", obz.ctx + "/weapp/sets/listAudits", params, function(resp){
		$(".itemsLotGrid").empty();
		if(resp && resp.list && resp.list.length>0){
			$('.itemsLotGrid').html(template('item_table_tr_tpl', resp));
			//初始化checkbox点击事件
			TBatch.checkCheckbox();
			TBatch.initCheckboxClick();
			TBatch.initOptEvent(TableOpt.init());
		}else{
			$(".itemsLotGrid").append($("#table_noresult_tr_tpl").html());
		}
	});
	table.init();
	var TableOpt = {
		configPub : function(param){
			var id = param[1];
			location.href = obz.ctx + "/weapp/sets/step1/"+id;
		}, 
		init : function(){
			var optArray = new Array();
			optArray.push(this.configPub);
			return optArray;
		}
	}
	
	$("#publish_online").click(function(){
		obz.showMessage("发布后会替换旧版本的小程序，确定发布吗?", function(){
			$("#mainTable").mask("发布中...");
			obz.ajaxJson("#(webctx)/weapp/sets/publish", function(resp){
				$("#mainTable").unmask();
				obz.msg("发布成功", function(){
					table.init();
				});
			}, function(){
				$("#mainTable").unmask();
			});
		});
	});
});
</script>